<?php
namespace app\api\controller\v1;

include EXTEND_PATH.'ali\aliyun-php-sdk-core\Config';
// use aliyun\video\core\config;
// use aliyun\video\core\DefaultProfile;
// use aliyun\video\core\DefaultAcsClient;
use vod\Request\V20170321 as vod;

$regionId = 'cn-shanghai';
$accessKeyId = "LTAIwVtRFNo540yc";
$accessKeySecret = "tt5xeSiP0Ql5vRHUnvX9OKdQW3vYO8";
$profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret);
$client = new DefaultAcsClient($profile);


class ali_Video{

	
	//获取视频上传凭证和地址
	public function create_upload_video() {
	    $request = new vod\CreateUploadVideoRequest();
	   	$accessKeyId = "LTAIwVtRFNo540yc";//参考本文档步骤2
	   	$accessKeySecret = "tt5xeSiP0Ql5vRHUnvX9OKdQW3vYO8";//参考本文档步骤2
		$regionId = 'cn-shanghai';

		$profile = DefaultProfile::getProfile($regionId, $access_key_id, $access_key_secret);
		$client = new DefaultAcsClient($profile);

		$request->setAcceptFormat('JSON');
	    //视频源文件标题(必选)
	    $request->setTitle("小海");
	    //视频源文件名称，必须包含扩展名(必选)
	    $request->setFileName("xiaohai.mp4");

	    $request->setFileSize(10240);
	    //视频源文件描述(可选)
	    $request->setDescription("视频描述1515616554");
	    //自定义视频封面URL地址(可选)
	    $request->setCoverURL("http://cover.sample.com/sample.jpg");
	    //上传所在区域IP地址(可选)
	    $request->setIP("127.0.0.1");
	    //视频标签，多个用逗号分隔(可选)
	    $request->setTags("云喵,前端");
	    ///视频分类ID(可选)
	    $request->setCateId(0);
	    $response = $client->getAcsResponse($request);
	    return $response;
	}
	//刷新视频上传凭证
	function refresh_upload_video() {
	    $request = new vod\RefreshUploadVideoRequest();
	    $accessKeyId = "LTAIwVtRFNo540yc";//参考本文档步骤2
	    $accessKeySecret = "tt5xeSiP0Ql5vRHUnvX9OKdQW3vYO8";//参考本文档步骤2
		$regionId = 'cn-shanghai';
		$profile = DefaultProfile::getProfile($regionId, $access_key_id, $access_key_secret);
		$client = new DefaultAcsClient($profile);
	    //视频ID(必选)
	    $request->setVideoId("1");
	    $response = $client->getAcsResponse($request);
	    return $response;
	}
}
